<!DOCTYPE html>
<html>
<head>
<title>订单详情</title>
[#include "/includes/header.html" /]







</head>

<body>

<input type="hidden" id="openid" value="${openid}" />


    <div class="weui-form-preview">
      <div class="weui-form-preview__hd">
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">订单状态</label>
          <em class="weui-form-preview__value">${orderDetail.orderStatus}</em>
        </div>
      </div>
      <div class="weui-form-preview__bd">
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">游客姓名</label>
          <span class="weui-form-preview__value">${orderDetail.uname}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">手机号码</label>
          <span class="weui-form-preview__value">${orderDetail.mobile}</span>
        </div>
          <div class="weui-form-preview__item">
              <label class="weui-form-preview__label">游玩日期</label>
              <span class="weui-form-preview__value">${orderDetail.ywtime}</span>
          </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">身份证号码</label>
          <span class="weui-form-preview__value">
          ${orderDetail.idnum}</span>
        </div>
      </div>
      
      <!-- 商品项 -->
       <div class="weui-form-preview__bd">
       <div class="weui-panel weui-panel_access">
		  <!-- <div class="weui-panel__hd">订单项</div> -->
		  <div class="weui-panel__bd">
		  	[#list orderDetail.orderItems as orderItem]
		    <a href="${webctx}/product/detail/?id=${orderItem.productId}" class="weui-media-box weui-media-box_appmsg">
		      <div class="weui-media-box__hd">
		        <img class="weui-media-box__thumb" src="${orderItem.productImg}">
		      </div>
		      <div class="weui-media-box__bd">
		        <h4 class="weui-media-box__title" style="font-size: 14px;">${orderItem.productName}</h4>
		        <p class="weui-media-box__desc">${orderItem.quantity}件</p>
		      </div>
		    </a>
		    [/#list]
		  </div>
		</div>
       </div>
      
      <div class="weui-form-preview__bd">
        <!-- <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">配送方式</label>
          <span class="weui-form-preview__value">免运费（快递发货）</span>
        </div> -->
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">买家留言</label>
          <span class="weui-form-preview__value">无</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">合计</label>
          <span class="weui-form-preview__value">￥${orderDetail.totalPrice}</span>
        </div>
        <!--<div class="weui-form-preview__item">-->
          <!--<label class="weui-form-preview__label">运费</label>-->
          <!--<span class="weui-form-preview__value">￥${orderDetail.postFee}</span>-->
        <!--</div>-->
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">应付金额</label>
          <span class="weui-form-preview__value">￥${orderDetail.payFee}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">订单编号</label>
          <span class="weui-form-preview__value">${orderDetail.orderSn}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">创建日期</label>
          <span class="weui-form-preview__value">${orderDetail.orderCreated}</span>
        </div>
      </div>
      
      [#if orderDetail.orderStatus == "待支付"]
      <div class="weui-form-preview__ft">
        <a id="zhifu" class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:void(0)">立即支付</a>
      </div>
      [/#if]
      
    </div>
[#include "/includes/footer.html" /]
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
<script type="text/javascript">


    //    订单支付
//    $("#zhifu").click(function(){
//        //发起支付
//        $.showLoading("正在连接微信支付...");
//        $.post("${webctx}/pay", {orderId:${orderDetail.orderId}}, function(data){
//            $.hideLoading();
//            var resp = data;
//            if(resp.code != 200){
//                $.alert(resp.msg==null ? "系统错误" : resp.msg);
//                return;
//            }
//        });
//    });

            /* 微信支付 */

    $("#zhifu").click( function (){
             $.showLoading("正在加载...");
             //测试时修改为自己的openId 如果不修改会出现【下单账号与支付账号不一致】的提示 这里最好授权获取
//            var openId="oL0ITwKvazqY7JBJhRF6RMgfZ0vM";
//                var openId =${openid};
             var openId = $("#openid").val();

             $.post("${webctx}/pay",
                 {
                     openId:openId,
                     total_fee:${orderDetail.payFee},
                     orderId:${orderDetail.orderId},
                 },
                 function(res){
                     $.hideLoading();
                     if (res.code == 0) {
                         var data=$.parseJSON(res.data);

                         if (typeof WeixinJSBridge == "undefined"){
                             if( document.addEventListener ){
                                 document.addEventListener('WeixinJSBridgeReady', onBridgeReady(data), false);
                             }else if (document.attachEvent){
                                 document.attachEvent('WeixinJSBridgeReady', onBridgeReady(data));
                                 document.attachEvent('onWeixinJSBridgeReady', onBridgeReady(data));
                             }
                         }else{
                             onBridgeReady(data);
                         }
                     }else{
                         if (res.code == 2) {
                             layer.alert(res.message) ;
                         }else{
                             layer.msg("参数错误："+res.message, {shift: 6});
                         }
                     }
                 });

         })




</script>


<script type="text/javascript">

    function onBridgeReady(json){
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            json,
            function(res){
                // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。
                if(res.err_msg == "get_brand_wcpay_request:ok" ) {
//                        layer.msg("支付成功!!!!", {shift: 6});

                    window.location.href="http://miaoxinchun.imwork.net/order";

                }else{
                    layer.msg("支付失败", {shift: 6});
                }
            }
        );
    }

</script>


</body>
</html>
